home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Stella Obscura 1.1 / source / Parts ƒ / GameBody.p < prev    next >
Encoding:
Text File  |  1990-05-13  |  3.3 KB  |  148 lines  |  [TEXT/PJMM]

  1. program Game;
  2.  
  3.     uses
  4.         LogoWindo, Sound, SomeGlobals, Utilities, mainWndo, Initialize, TheMenus;
  5.     var
  6.         theEvent: EventRecord;
  7.         doneFlag: boolean;
  8.         code, superFix, suffix: integer;
  9.         whichWindow: WindowPtr;
  10.         mResult, dummyLong: longint;
  11.         theMenu, theItem: integer;
  12.         chCode: integer;
  13.         ch: char;
  14.         theInput: TEHandle;
  15.         thisWorld: SysEnvRec;
  16.         err: OSErr;
  17.  
  18. {===================================}
  19.  
  20. begin
  21.     MoreMasters;
  22.     MoreMasters;
  23.     MoreMasters;
  24.     InitCursor;
  25.     doneFlag := FALSE;
  26.     SetCursor(GetCursor(WatchCursor)^^);
  27.     Init_My_Menus;
  28.     Init_LogoWindo;
  29.     Open_LogoWindo;
  30.     err := SysEnvirons(1, thisWorld);
  31.     with thisWorld do
  32.         begin
  33.             if (machineType < 2) then
  34.                 ExitToShell
  35.             else
  36.                 begin
  37.                     superFix := systemVersion div 256;
  38.                     suffix := systemVersion - superFix;
  39.                     if (superFix >= 6) and (suffix >= 2) then
  40.                         forgetSound := FALSE
  41.                     else
  42.                         forgetSound := TRUE;
  43.                 end;
  44.         end;
  45.     if forgetSound then
  46.         begin
  47.             SetItem(GetMenu(OptionsM), 1, 'Sound needs Sys 6.02 or >');
  48.             DisableItem(GetMenu(OptionsM), 1);
  49.         end;
  50.     InitVariables;
  51.     theInput := nil;
  52.     InitCursor;
  53.     Close_LogoWindo;
  54.     Init_mainWndo;
  55.     BringUpStartUp;
  56.     DoTheVirgin;
  57.     UpDate_mainWndo(mainWndo);
  58.     SetEventMask(idleMask);
  59.     FlushEvents(everyEvent, 0);
  60.  
  61.     repeat
  62.         SystemTask;
  63.  
  64.         if GetNextEvent(everyEvent, theEvent) then
  65.             begin
  66.                 code := FindWindow(theEvent.where, whichWindow);
  67.                 case theEvent.what of
  68.                     MouseDown: 
  69.                         begin
  70.                             if (code = inMenuBar) then
  71.                                 begin
  72.                                     mResult := MenuSelect(theEvent.Where);
  73.                                     theMenu := HiWord(mResult);
  74.                                     theItem := LoWord(mResult);
  75.                                     Handle_My_Menu(doneFlag, theMenu, theItem, theInput);
  76.                                 end;
  77.                             if (code = inContent) then
  78.                                 begin
  79.                                 end;
  80.                             if (code = inSysWindow) then
  81.                                 SystemClick(theEvent, whichWindow);
  82.                         end;
  83.                     KeyDown, AutoKey: 
  84.                         begin
  85.                             with theEvent do
  86.                                 begin
  87.                                     chCode := BitAnd(message, CharCodeMask);
  88.                                     ch := CHR(chCode);
  89.                                     if (Odd(modifiers div CmdKey)) then
  90.                                         begin
  91.                                             mResult := MenuKey(ch);
  92.                                             theMenu := HiWord(mResult);
  93.                                             theItem := LoWord(mResult);
  94.                                             if (theMenu <> 0) then
  95.                                                 Handle_My_Menu(doneFlag, theMenu, theItem, theInput);
  96.                                         end;
  97.                                 end;
  98.                         end;
  99.                     UpDateEvt: 
  100.                         if (not playing) then
  101.                             begin
  102.                                 whichWindow := WindowPtr(theEvent.message);
  103.                                 BeginUpdate(whichWindow);
  104.                                 Update_mainWndo(whichWindow);
  105.                                 EndUpdate(whichWindow);
  106.                             end;
  107.                     otherwise
  108.                         begin
  109.                         end;
  110.                 end;
  111.             end;
  112.  
  113.         if playing and (not pausing) then
  114.             begin
  115.                 SetShipsPos;
  116.                 if (hoopOut) then
  117.                     ComputeHoops
  118.                 else
  119.                     UpDateEnemy;
  120.                 DrawScene;
  121.                 if GameOver then
  122.                     WrapItUp;
  123.                 if slowOn then
  124.                     Delay(10, dummyLong);
  125.             end;
  126.  
  127.     until doneFlag;                       {End of the event loop}
  128.  
  129.     if (chanPtr <> nil) then
  130.         err := SndDisposeChannel(chanPtr, FALSE);
  131.  
  132.     HUnlock(Handle(leftScreenRgn));
  133.     DisposeRgn(leftScreenRgn);
  134.     HUnlock(Handle(rightScreenRgn));
  135.     DisposeRgn(rightScreenRgn);
  136.  
  137.     ClosePort(offPlayerPort);
  138.     DisposPtr(Ptr(offPlayerPort));
  139.     ClosePort(offRightPort);
  140.     DisposPtr(Ptr(offRightPort));
  141.     ClosePort(offLeftPort);
  142.     DisposPtr(Ptr(offLeftPort));
  143.     ClosePort(offLeftVirginPort);
  144.     DisposPtr(Ptr(offLeftVirginPort));
  145.     ClosePort(offRightVirginPort);
  146.     DisposPtr(Ptr(offRightVirginPort));
  147.  
  148. end.                                    {End of the program}